package org.hs.phd.odi.tracking.tracker.kernel;

public abstract class AbstractKernel implements Kernel {

	public AbstractKernel(){
	}
	
    /* (non-Javadoc)
	 * @see org.hs.phd.odi.tracking.tracker.kernel.Kernel#value(float, float)
	 */
    @Override
	public final float value(float x, float y) {
        float r2 = x * x + y * y;
        float value = (r2 > 1) ? 0 : kernelFunction(r2);
        return value;
    }

	/* (non-Javadoc)
	 * @see org.hs.phd.odi.tracking.tracker.kernel.Kernel#derivative(float, float)
	 */
    @Override
	public final float derivative(float x, float y) {
        float r2 = x * x + y * y;
        float value = (r2 > 1 ) ? 0 : kernelFunctionDerivative(r2);
        return value;
    }
    
    protected abstract float kernelFunction(float normalizedDistanceSquared);
    protected abstract float kernelFunctionDerivative(float normalizedDistanceSquared);

}
